﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Messaging;

namespace APH.Parl2.Services.PubSub
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing publish events services...");
            
            if (MessageQueue.Exists(@".\private$\PublishEventServiceQueue") == false)
            {
                MessageQueue.Create(@".\private$\PublishEventServiceQueue", true);
            }

            ServiceHost publishServiceHost = new ServiceHost(typeof(PublishEventService), new Uri("http://localhost:5000"));
            publishServiceHost.Open();
            
            ServiceHost subscriptionManagerHost = new ServiceHost(typeof(PublishSubscriptionService), new Uri("http://localhost:6000"));
            subscriptionManagerHost.Open();

            Console.WriteLine("Publish events services online.");
            Console.WriteLine("\nPress escape to exit.\n");

            while (true)
            {
                if (Console.ReadKey(true).Key == ConsoleKey.Escape)
                    break;
            }

            publishServiceHost.Close();
            subscriptionManagerHost.Close();
        }
    }
}
